using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using DailyReport.Core.Bussines;
using DailyReport.Core.Bussines.IManagers;
using DailyReport.Core.Data.Dao;
using DailyReport.Core.Data.Dao.DaoFactory;
using DailyReport.Core.Data.Model;
using DailyReport.Core.Util;
using DailyReport.NHibernateDao.Data.Dao;
using log4net;
using NHibernate;

public partial class Pages_Teams_CreateTeam : System.Web.UI.Page
{

    private UserManager um = new UserManager();
    private TeamManager tm = new TeamManager();
    static ILog log = LogManager.GetLogger("DailyPage");

    protected void Page_Load(object sender, EventArgs e)
    {
        ISession session = ConnectionManager.Instance.Session;
        ddlManager.Items.Add("");
        UserDao userDao = new UserDao();
        userDao.Session = session;
        foreach(User user in userDao.GetAll())
        {            
            ListItem item=new ListItem(user.LastName+"; "+user.FirstName,user.ID.ToString());
            ddlManager.Items.Add(item);            
        }        
        

        ddlParentTeam.Items.Add("");        
        TeamDao teamDao = new TeamDao();
        teamDao.Session = session;
        foreach(Team team in teamDao.GetAll())
        {            
            ListItem item=new ListItem(team.Name,team.ID.ToString());
            ddlParentTeam.Items.Add(item);
        }
        
        

    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        int parenteam = int.Parse(ddlParentTeam.SelectedValue);
        int manager = int.Parse(ddlManager.SelectedValue);
        tm.createTeam(parenteam, txtName.Text, manager);
        Server.Transfer("~/Pages/Teams/ListTeam.aspx");
    }
    protected void btnCancel_Click(object sender, EventArgs e)
    {
        Server.Transfer("~/Pages/Teams/ListTeam.aspx");
    }
}
